package com.example.mapper;

import com.example.entity.HealthRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface HealthRecordMapper {

    @Insert("INSERT INTO health_records (user_id, record_date, sleep_hours, sedentary_alerts, period_status) " +
            "VALUES (#{userId}, #{recordDate}, #{sleepHours}, #{sedentaryAlerts}, #{periodStatus})")
    int insertHealthRecord(HealthRecord record);

    @Delete("DELETE FROM health_records WHERE record_id = #{recordId}")
    int deleteHealthRecordById(Integer recordId);

    @Update("UPDATE health_records SET sleep_hours = #{sleepHours}, sedentary_alerts = #{sedentaryAlerts}, " +
            "period_status = #{periodStatus} WHERE record_id = #{recordId}")
    int updateHealthRecord(HealthRecord record);

    @Select("SELECT * FROM health_records WHERE user_id = #{userId} ORDER BY record_date DESC")
    List<HealthRecord> getHealthRecordsByUserId(Integer userId);
}
